import { E_EffectFlag, E_EffectType, I_Effect } from "../BattleConst";

/**
 * buff管理器
 */
export default class BattleUnitEffectMgr {
    private _effects: Map<E_EffectType, I_Effect> = new Map();

    addEffect(effect: I_Effect) {
        let oldEff = this._effects.get(effect.effType);
        if (oldEff) {//已有同类型buff，判断叠加还是替换
            if (effect.effFlag == E_EffectFlag.ADD) {
                oldEff.sustain_round += effect.sustain_round;
            } else if (effect.effFlag == E_EffectFlag.REPLACE) {
                this._effects.set(effect.effType, effect);
            }
        } else {
            this._effects.set(effect.effType, effect);
        }
    }

    getEffect(type: E_EffectType) {
        return this._effects.get(type)
    }

    /**根据timing触发buff */
    applyEffects(timing: string) {

    }
} 